"""
json转对象

Version: 0.1
Author: yuwl
Date：2024-4-07
"""

import json
import csv2

json_str = '{"name": "张三", "age": 28, "title": "砖家"}'
model = json.loads(json_str)
print(model)
print(type(model)) # <class 'dict'>
print(model['name'])
print(model['age'])

# 把转换得到的字典作为关键字参数传入Teacher构造器
teacher = csv2.Teacher(**model)
print(teacher)
print(teacher.name)
print(teacher.age)
print(teacher.title)